home *** CD-ROM | disk | FTP | other *** search
- Path: walrus.megabaud.fi!not-for-mail
- From: petrin@walrus.megabaud.fi (Petri Nordlund)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Breaking another task
- Date: 12 Jan 1996 22:35:16 +0200
- Organization: Megabaud Oy,Helsinki,Finland
- Message-ID: <4d6gm4$r0f@walrus.megabaud.fi>
- NNTP-Posting-Host: walrus.megabaud.fi
-
- Tom Parker <tparker@amiga3k.codeworks.gen.nz> writes:
-
- >I have written a program that puts a window on my editor's screen with a
- >button to abort my compiler while it is compiling. It works great, but it does
- >it in a very nasty way.
- >
- >I call executive's ps command, parse its output, and then send it to
- >executive's kill command, to kill my smake and all its subtasks.
-
- Are you using the PGRP-option (process group) of Kill? You can
- kill smake and its subtasks by issuing the command:
-
- Kill PGRP=<PID of smake>
-
- >What i would like to know, is how do i do what ps & kill do. At the very least
- >i want to find the task structure of the compiler, so i can signal it, but i
- >would like to be able to kill all the subtasks of smake, and smake itself,
- >rather than single out the compiler.
-
- It's not very easy. You'll first have to find the smake-task, but
- you can't use exec.library's FindTask()-function, because the task
- name is not "smake". So you'll have to manually browse Exec's
- tasklists and for each task, check if it's a process. If it is,
- check if it has a CLI-structure (pr_Cli). You'll find the CLI command
- name in the cli_CommandName field, which is a BSTR, i.e. the first byte
- is the string length and the string is not NULL terminated.
-
- When you have the task, you can kill it with Signal()ing it, but
- you can't kill the subtasks, because Exec doesn't currently maintain
- a child-parent relationships of tasks. Executive does this by patching
- AddTask() and RemTask().
-
- >I don't mind using executive's functions, if they will do this easier than the
- >normal system functions.
-
- I could add support to SysInfo.library for killing process groups,
- currently it can only renice process groups.
- --
- __
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Petri Nordlund __/// petrin@megabaud.fi
- ---------------------------------\XX/----------------------------------
-